// 03myCenter/02sectorization/01myChange/financialDetails/financialDetails.js

var co = require('../../../../resource/js/common.js')
var page = 1
var app = getApp()
var _this

Page({
   /*页面的初始数据*/
   data: {
      details: [],
      userMoney: [],
      hint: false,
      Self_Payer: '' //自已Payer，用于判断充值情况
   },
   /* 生命周期函数--监听页面加载*/
   onLoad: function(options) {
      _this = this
      this.setData({
         Self_Payer: 'User_' + app.Data.userInfo.User_ID
      })
      this.getDetails()
   },
   onReachBottom: function() {
      this.getDetails()
   },

   // 获取财务明细
   getDetails() {
      var param = {
         // app.Data.userInfo.User_ID
         User_ID: app.Data.userInfo.User_ID,
         //Biz_ID:75
         page: page
      }
      co.getJyhsApi('money/Recorduser/getList', param, function(res) {
         if (res.code == 0) {
            page++
            console.log("res===", res)
            var list = _this.data.details
            //console.log(list)
            _this.setData({
               details: list.concat(res.data)
            })
            console.log('_this.details2===', _this.data.details)
         } else {
            _this.setData({
               hint: true
            })
         }   
      })
   },
   // 加载更多
   setLoading: function(e) {
      _this.getDetails()
   },


   //item点击事件
   itemClick: function(e) {
      console.log('e====', e)
      var index = e.currentTarget.id
      var obj = _this.data.details[index]
      //console.log(obj)
      wx.navigateTo({
         url: '/04myCenter/01myWallet/01myChange/financialDetails/moneyRecDetail/moneyRecDetail?detail=' + JSON.stringify(obj),
      })
   },
   
   /*生命周期函数--监听页面卸载 */
   onUnload: function() {
      page = 1
   },
})